#!/usr/bin/env python
# coding=utf-8
#-------------------------------------------------------------------------------
# Name:        模块1
# Purpose:
#
# Author:      vavava
#
# Created:     05/11/2012
# Copyright:   (c) vavava 2012
# Licence:     <your licence>
#-------------------------------------------------------------------------------

__author__ = 'vavava'


class LogAdapter(object):

    def __init__(self,log=None,mod_name="<undefine_module_name>"):
        self.LOG = log
        self.mod_name=mod_name
        if mod_name is None:
            self.mod_name="<undefine_module_name>"

    def info(self,arg):
        if self.LOG:
            self.LOG.info(arg)
        else:
            print('[',self.mod_name,'(info)]',arg)

    def warn(self,arg):
        if self.LOG:
            self.LOG.warn(arg)
        else:
            print('[',self.mod_name,'(warm)]',arg)

    def error(self,arg):
        if self.LOG:
            self.LOG.error(arg)
        else:
            print('[',self.mod_name,'(error)]',arg)

    def debug(self,arg):
        if self.LOG:
            self.LOG.debug(arg)
        else:
            print('[',self.mod_name,'(debug)]',arg)

    def exception(self,e):
        if self.LOG:
            self.LOG.exception(e)
        else:
            print('[',self.mod_name,'(exception)]',e)

